//
//  UIs_EPEnergy_DemoVC.swift
//  APSwift
//
//  Created by jianbo.pei on 2022/4/12.
//

import UIKit
import APExtensions

extension UIView {
    /// height: 视图的高度
    var height: CGFloat {
        get {
            return frame.size.height
        }
        set {
            var tempFrame: CGRect = frame
            tempFrame.size.height = newValue
            frame = tempFrame
        }
    }
    
    /// y 的位置
    var y: CGFloat {
        get {
            return frame.origin.y
        }
        set(newValue) {
            var tempFrame: CGRect = frame
            tempFrame.origin.y = newValue
            frame = tempFrame
        }
    }
}

class UIs_EPEnergy_DemoVC: UIViewController {

    private var topImageView: UIImageView!
    private var bottomImageView: UIImageView!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        let imgW = 94.0
        let imgX = (ap_kScreenW - imgW) / 2.0
        topImageView = UIImageView(frame: CGRect(x: imgX, y: 300, width: imgW, height: 11))
        topImageView.image = UIImage(named: "ep_energy_top")
        view.addSubview(topImageView)
        
        bottomImageView = UIImageView(frame: CGRect(x: imgX, y: 305.5, width: imgW, height: 21.5))
        if let img = UIImage(named: "ep_energy_bottom") {
            bottomImageView.image = img.stretchableImage(withLeftCapWidth: 47, topCapHeight: 11)
        }
        view.addSubview(bottomImageView)
       
    }
    

    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        bottomImageView.height += 5
        bottomImageView.y -= 5
        topImageView.y -= 5
    }

}
